<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/10
 * Time: 13:42
 */

namespace App\Http\Requests\User;

use App\Http\Requests\ApiRequest;
use Illuminate\Validation\Rule;

class AddManageUserRequest extends ApiRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * 'permission/permission_manage/PermissionList'：前端路由
     *
     * @return bool
     */
    public function authorize()
    {
        if(is_bool(self::checkPermission('permission/permission_manage/PermissionList'))){
            return self::checkPermission('permission/permission_manage/PermissionList');
        }else{
            return false;
        }
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'username'=>'required',
            'mobile'=>'required',
            'user_type'=>'required|integer',
            'password'=>'required|integer',
            'gender'=>'integer',
            'signature'=>'integer',
            'status' => 'integer',
            ];
    }

    /**
     * 获取已定义验证规则的错误消息。
     *
     * @return array
     */
    public function messages()
    {
        return [
            'username.required'=>'缺少用户名',
            'mobile.required'=>'缺少电话',
            'user_type.required'=>'缺少用户类型',
            'user_type.integer'=>'用户类型为整型',
            'password.required'=>'缺少密码',
            'status.integer'=>'状态类型为整型',
            ];
    }
}